package com.zzyl.task;

import com.zzyl.service.CustomerReservationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author sjqn
 */
@Component
@Slf4j
public class MyTask {
    @Autowired
    private CustomerReservationService customerReservationService;
    /**
     * 定时任务 每小时的1分钟和31分钟自动检查
     */
    @Scheduled(cron = "0 1,31 * * * ?")
    public void executeTask(){
        log.info("定时任务开始执行：{}", LocalDateTime.now());
        customerReservationService.updateReservationStatus(LocalDateTime.now());
    }
}